package ch10.d2;

import org.junit.Test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;

//字符流
public class ReaderTest {
    @Test
    public void testRead() throws IOException {
        Reader reader = new FileReader("javakc107.txt");
        int n=reader.read();
        System.out.println(n);
        reader.close();

    }

    @Test
    public void testRead2() throws IOException {
        Reader reader = new FileReader("javakc107.txt");
        char[] c=new char[3];
        int n=0;
        while ((n=reader.read(c))!=-1){
            System.out.println(Arrays.toString(c));
            String s=new String(c,0,n);
            System.out.println(s);
        }
        reader.close();
    }
}
